#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

void backtrack(std::vector<int> & a, int size_a, int k, int n, const std::vector<int> &c){
	if(k == 0) {
		for(int i = 0; i < size_a; ++i){
			std::cout << a[i] << ' ';
		}
		std::cout << std::endl;
		return;
	}
	else if (k == n){
		std::copy(c.begin(), c.begin()+k, a.begin()+size_a);
		size_a += k;
		for(int i = 0; i < size_a; ++i){
			std::cout << a[i] << ' ';
		}
		std::cout << std::endl;
		return;
	}
	else {
		a[size_a] = c[n-1];
		backtrack(a,size_a+1,k-1,n-1,c);
		backtrack(a,size_a, k, n-1,c);
	}
}

void test_backtrack_combination(){
	int c[] = {1, 2, 3};
	int n = sizeof(c)/sizeof(int);
	std::vector<int> cv(c,c+n);
	int k = 0;
	std::vector<int> a(k);
	backtrack(a,0,k,n,cv);
}